package com.atguigu.my.chapter01

import util.control.Breaks._

/**
 *
 * @description: xxx
 * @time: 2020-05-22 11:08
 * @author: baojinlong 
 **/
object HomeWork {
  def main(args: Array[String]): Unit = {
    var sum = 0
    breakable {
      for (i <- 1 to 100) {
        sum += i
        if (sum > 20) {
          println("第一次大于20的当前数=" + i)
          break()
        }
      }
    }
    sum = 0
    var flag = true
    for (i <- 1 to 100 if flag) {
      sum += i
      if (sum > 20) {
        println("第一次大于20的当前数=" + i)
        flag = false
      }
    }
  }
}
